package project.dbaccesslayer;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import project.model.adt.Answer;

public class Table_SO_Answers {

	public static void saveAnswers(Connection conn, List<Answer> answers,Long questionId)
			throws SQLException {

		PreparedStatement s = conn
				.prepareStatement("INSERT INTO SO_Answers"
						+ "(Question_id,Answer_id,User_id,Descr,Date_Answered,Votes) VALUES(?,?,?,?,?,?)");
		for (Answer ans : answers) {
			s.setLong(1, questionId);
			s.setLong(2, ans.answerID);
			s.setLong(3, ans.userId);
			s.setString(4, ans.description);
			s.setLong(5, ans.dateAnswered);
			s.setLong(6, ans.votes);
			s.executeUpdate();
		}

	}

}
